home *** CD-ROM | disk | FTP | other *** search
/ The Charlie Rose Science Series Anthology / The Charlie Rose Science Series Anthology (Pfizer, Inc.)(2008).iso / mac / Charlie Rose Science Series Anthology.app / Contents / Resources / movie.swf / scripts / __Packages / mx / controls / streamingmedia / PlayBarThumb.as < prev    next >
Text File  |  2008-02-01  |  4KB  |  139 lines

  1. class mx.controls.streamingmedia.PlayBarThumb extends MovieClip
  2. {
  3.    function PlayBarThumb()
  4.    {
  5.       super();
  6.       this.init();
  7.    }
  8.    function init()
  9.    {
  10.       this._playBar = this._parent;
  11.       this.__set__enabled(this._playBar.getController().enabled);
  12.    }
  13.    function isVertical()
  14.    {
  15.       return this._playBar.isVertical();
  16.    }
  17.    function handlePress()
  18.    {
  19.       this.startThumbDrag();
  20.    }
  21.    function startThumbDrag()
  22.    {
  23.       this._dragging = true;
  24.       var _loc2_ = this._playBar.getController();
  25.       _loc2_.broadcastEvent("scrubbing",true);
  26.       this._wasPlaying = _loc2_.isPlaying();
  27.       if(this._wasPlaying)
  28.       {
  29.          _loc2_.broadcastEvent("click","pause");
  30.       }
  31.       this.onMouseMove = this.handleMouseMove;
  32.    }
  33.    function onUnload()
  34.    {
  35.       if(this._dragging)
  36.       {
  37.          this.stopThumbDrag();
  38.       }
  39.    }
  40.    function handleRelease()
  41.    {
  42.       if(this._dragging)
  43.       {
  44.          this.stopThumbDrag();
  45.       }
  46.    }
  47.    function handleReleaseOutside()
  48.    {
  49.       if(this._dragging)
  50.       {
  51.          this.stopThumbDrag();
  52.       }
  53.    }
  54.    function stopThumbDrag()
  55.    {
  56.       this._dragging = false;
  57.       var _loc2_ = this._playBar.getController();
  58.       if(this._wasPlaying)
  59.       {
  60.          _loc2_.broadcastEvent("click","play");
  61.       }
  62.       _loc2_.broadcastEvent("scrubbing",false);
  63.       delete this.onMouseMove;
  64.    }
  65.    function handleMouseMove()
  66.    {
  67.       var _loc2_ = this._playBar.getController();
  68.       var _loc8_ = _loc2_.getLoadBar().getCompletionPercentage() / 100;
  69.       if(this.isVertical())
  70.       {
  71.          var _loc6_ = this._playBar.getHeight() - 8;
  72.          var _loc9_ = _loc6_ * (1 - _loc8_) - 2;
  73.          var _loc3_ = this._playBar._ymouse;
  74.          if(_loc3_ < _loc9_)
  75.          {
  76.             _loc3_ = _loc9_;
  77.          }
  78.          else if(_loc3_ > _loc6_)
  79.          {
  80.             _loc3_ = _loc6_;
  81.          }
  82.          this._y = _loc3_;
  83.       }
  84.       else
  85.       {
  86.          var _loc10_ = (this._playBar.getWidth() - 6) * _loc8_;
  87.          var _loc4_ = this._playBar._xmouse;
  88.          if(_loc4_ < 0)
  89.          {
  90.             _loc4_ = 0;
  91.          }
  92.          else if(_loc4_ > _loc10_)
  93.          {
  94.             _loc4_ = _loc10_;
  95.          }
  96.          this._x = _loc4_;
  97.       }
  98.       this._playBar.updateHiliteToMatchThumb();
  99.       var _loc5_ = !this.isVertical() ? this._playBar.xToPercent(this._x) : this._playBar.yToPercent(this._y);
  100.       if(mx.controls.streamingmedia.StreamingMediaConstants.SCRUBBING)
  101.       {
  102.          _loc2_.broadcastEvent("playheadChange",_loc5_);
  103.       }
  104.       var _loc11_ = _loc2_.__get__playTime() * 100 / _loc2_.__get__playPercent();
  105.       var _loc7_ = _loc11_ * _loc5_ / 100;
  106.       this._playBar.setTime(_loc7_);
  107.       _loc2_.__set__playPercent(_loc5_);
  108.       _loc2_.__set__playTime(_loc7_);
  109.    }
  110.    function get enabled()
  111.    {
  112.       return this._enabled;
  113.    }
  114.    function set enabled(is)
  115.    {
  116.       this._enabled = is;
  117.       if(is)
  118.       {
  119.          this.onPress = this.handlePress;
  120.          this.onRelease = this.handleRelease;
  121.          this.onReleaseOutside = this.handleReleaseOutside;
  122.       }
  123.       else
  124.       {
  125.          if(this._dragging)
  126.          {
  127.             this.stopThumbDrag();
  128.          }
  129.          delete this.onPress;
  130.          delete this.onRelease;
  131.          delete this.onReleaseOutside;
  132.       }
  133.    }
  134.    function isScrubbing()
  135.    {
  136.       return this._dragging;
  137.    }
  138. }
  139.